<template>
  <div class="flex-center">
    <div class="box" style="width: 800px;height:800px;border: 1px solid silver">
      <el-card style="width: 800px;height:800px;" class="form-container" shadow="never">
        <el-form :model="productAttr" ref="productAttrFrom" label-width="150px">
          <el-form-item label="属性名称：" prop="name">
            <el-input v-model="productAttr.name"></el-input>
          </el-form-item>
          <el-form-item label="商品类型：">
            <el-select v-model="productAttr.productAttributeCategoryId" placeholder="请选择">
              <el-option
                v-for="item in productAttrCateList"
                :key="item.id"
                :label="item.name"
                :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="分类筛选样式:">
            <el-radio-group v-model="productAttr.filterType">
              <el-radio :label="0">普通</el-radio>
              <el-radio :label="1">颜色</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="能否进行检索:">
            <el-radio-group v-model="productAttr.searchType">
              <el-radio :label="0">不需要检索</el-radio>
              <el-radio :label="1">关键字检索</el-radio>
              <el-radio :label="2">范围检索</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="商品属性关联:">
            <el-radio-group v-model="productAttr.relatedStatus">
              <el-radio :label="1">是</el-radio>
              <el-radio :label="0">否</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="属性是否可选:">
            <el-radio-group v-model="productAttr.selectType">
              <el-radio :label="0">唯一</el-radio>
              <el-radio :label="1">单选</el-radio>
              <el-radio :label="2">复选</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="属性值的录入方式:">
            <el-radio-group v-model="productAttr.inputType">
              <el-radio :label="0">手工录入</el-radio>
              <el-radio :label="1">从下面列表中选择</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="属性值可选值列表:">
            <el-input :autosize="true" type="textarea" v-model="inputListFormat"></el-input>
          </el-form-item>
          <el-form-item label="是否支持手动新增:">
            <el-radio-group v-model="productAttr.handAddStatus">
              <el-radio :label="1">是</el-radio>
              <el-radio :label="0">否</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="排序属性：">
            <el-input v-model="productAttr.sort"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit('productAttrFrom')">提交</el-button>
            <el-button v-if="!isEdit" @click="resetForm('productAttrFrom')">重置</el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </div>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）,
//例如：import 《组件名称》 from '《组件路径》,
import {findById} from "@/api/product/attributeCategory";

const defaultProductAttr = {
  filterType: 0,
  handAddStatus: 0,
  inputList: '',
  inputType: 0,
  name: '',
  productAttributeCategoryId: 0,
  relatedStatus: 0,
  searchType: 0,
  selectType: 0,
  sort: 0,
  type: 0
};
export default {
  //import引入的组件需要注入到对象中才能使用"
  components: {},
  props: {},
  data() {
    //这里存放数据"
    return {
      productAttr: Object.assign({}, defaultProductAttr),
      productAttrCateList: null,
      inputListFormat:null
    };
  },
  //计算属性 类似于data概念",
  computed: {},
  //监控data中的数据变化",
  watch: {},
  //方法集合",
  methods: {
    findById(){
      findById(this.$route.query.cid).then(res=>{
        console.log(res)
        this.productAttr = res.data;
      })
    },


    getAttrList(index, row) {
      console.log(row)
      this.$router.push({path: '/product/addProductAttribute', query: {cid: row.id, cname: row.name, type: 0}})
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）",
  created() {
    this.findById();
  },
  //生命周期 - 挂载完成（可以访问DOM元素）",
  mounted() {
  },
  beforeCreate() {
  }, //生命周期 - 创建之前",
  beforeMount() {
  }, //生命周期 - 挂载之前",
  beforeUpdate() {
  }, //生命周期 - 更新之前",
  updated() {
  }, //生命周期 - 更新之后",
  beforeDestroy() {
  }, //生命周期 - 销毁之前",
  destroyed() {
  }, //生命周期 - 销毁完成",
  activated() {
  } //如果页面有keep-alive缓存功能，这个函数会触发",
};
</script>
<style scoped>
.flex-center {
  display: flex;
  justify-content: center; /* 水平居中 */
  align-items: center; /* 垂直居中 */
  height: 80vh; /* 假设你想要盒子在视口中垂直居中 */
}

.box {
  /* 你的盒子样式 */
}
</style>


